package com.glut.gultguy.controller;


import com.glut.gultguy.entity.User;
import com.glut.gultguy.mapper.UserMapper;
import com.glut.gultguy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2022-09-05
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService service;

    @Autowired(required = false)
    private UserMapper mapper;

    @GetMapping("/getUserInfo/{id}")
    public User getUserInfo(@PathVariable("id") String _openid){
        return service.getUserInfo(_openid);
    }

    @PostMapping("/addUser")
    @ResponseBody
    public User addUser(@RequestBody User user){
        return service.addUser(user);
    }

    @GetMapping("/getUserById/{id}")
    public User getUserById(@PathVariable("id") String id){
        return service.getById(id);
    }
}

